package com.test.feigndemo.interceptor;

import feign.RequestInterceptor;
import feign.RequestTemplate;

import java.util.Random;
import java.util.UUID;


public class FeignAuthRequestInterceptor implements RequestInterceptor {
    @Override
    public void apply(RequestTemplate template) {
        // 业务逻辑  模拟认证逻辑

        String str="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
        Random random=new Random();
        StringBuffer sb=new StringBuffer();
        for(int i=0;i<10;i++) {
            int number = random.nextInt(62);
            sb.append(str.charAt(number));
        }

        String access_token = sb.toString();
        template.header("Authorization",access_token);
    }
}
